package com.joker.storehelper.client.android;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;


/**
 * A placeholder fragment containing a simple view.
 */
public class MainActivityFragment extends Fragment {

    public MainActivityFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.fragment_main, container, false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Button startScan = getActivity().findViewById(R.id.start_scan_btn);
        startScan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.putExtra("mode",2);
                intent.setClassName(getActivity(), CaptureActivity.class.getName());
                startActivity(intent);
            }
        });

        Button startImportScan = getActivity().findViewById(R.id.start_scan_import);
        startImportScan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.putExtra("mode",1);
                intent.setClassName(getActivity(), CaptureActivity.class.getName());
                startActivity(intent);
            }
        });
        /*Button showGoods = getActivity().findViewById(R.id.show_goods_btn);
        showGoods.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setClassName(getActivity(), GoodsListFragment.class.getName());
                startActivity(intent);
            }
        });*/
    }
}
